package com.findme.gui;

import com.findme.controller.ControllerUsuario;
import com.findme.findme.R;
import com.findme.model.Usuario;
import com.findme.uteis.alertaDialog;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;

public class TelaNovoMembro extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_tela_novo_membro);
				
		//nova conta de membro
		ImageView  imgNovaConta  = (ImageView) findViewById(R.id.imgVwNovaConta);
		
		imgNovaConta.setOnClickListener(new View.OnClickListener() {
			
		public void onClick(View v) {
			
			//pega dados do cadastro
			EditText  edtEmail  = (EditText) findViewById(R.id.edtEmail);
			EditText  edtnome   = (EditText) findViewById(R.id.edtNome);
			EditText  edtfone   = (EditText) findViewById(R.id.edtFone);
			EditText  edtsenha  = (EditText) findViewById(R.id.edtSenha);
						 	
			//popula classe para inclusao
	     	Usuario user = new Usuario();
	     	user.setEmail(edtEmail.getText().toString());
	     	user.setNome (edtnome.getText().toString());   	
	     	user.setFone(edtfone.getText().toString());
	     	user.setSenha (edtsenha.getText().toString());
	     					
			//cria controlador
		    ControllerUsuario ct = new ControllerUsuario(user);
			    		     	
		    //se gravou fecha a activity
		    if (ct.incluir(TelaNovoMembro.this)){
			    finish();
			}
			    
		    edtEmail=null;
			edtnome=null;
		    edtfone=null;
		    edtsenha=null;

			}
			
		});			
		
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.tela_novo_membro, menu);
		return true;
	}

}
/*
		     	Usuario user = new Usuario();
				    ControllerUsuario ct = new ControllerUsuario(user);
				    
			       if(ct.logar(TelaLogin.this.getApplicationContext())){//se logou com sucesso
			    	   
				     //chama a activity principal
				     Intent i = new Intent(TelaLogin.this, TelaPrincipal.class);
				     startActivityForResult(i, 1);
				     finish();	
				     
			       }
 */